<?php

namespace App\Http\Controllers\Counter;

use App\Http\Controllers\Controller;
use App\LeShua\LeShuaNotify;
use App\Models\OnlineTradeOrder;
use Illuminate\Http\Request;

class OrderNotifyController extends Controller
{
    public function leshuaPay(Request $request)
    {
        $xmlData = $request->getContent();
        $response = new LeShuaNotify($xmlData);
        $orderNo = $response->getSelfOrderNo();

        if ($response->getStatus() == 2) {
            $trade = OnlineTradeOrder::where('order_no', $orderNo)->first();
            if (!empty($trade)) {
                $trade->payed();
            }
        }

        return "000000";
    }
}
